import requests

piclab_headers = {
    'Host': 'piclab.org',
    'Origin': 'http://piclab.org',
    'Cookie': 'session=.eJwljkEOwzAIBP_icw-ADYF8JjIGq70mzanq32up11nNaj7lmGdez7K_zzsf5XhF2Ut0iZ4aPGT23AYKp6J1gDpmDx0LKdNatcuGbGFkOmgZ7JNVLQjYxZy9AjWs667Oxq4boaFCWhNobhDuk6I60agxzaWKQ1kh95XnvwbL9wcAtC95.ZNDqnQ.JQvnv2gIMhx-8dGsLC-6aRFn3_g'
}
piclab_url = 'http://piclab.org/api/upload'


def upload(filename, img_dict):
    data = {'file_md5': img_dict['md5'], 'file_size': img_dict['content_length']}
    files = [
        ('file', (filename, img_dict['img_buffer'].getvalue())),
        ('file', (filename, img_dict['thumb_buffer'].getvalue())),
    ]
    response = requests.post(piclab_url, headers=piclab_headers, data=data, files=files)
    # print(response.status_code, response.json())
    return response.json()
